package com.tangjia.daiban;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tangjia.daiban.Bean.Item;

import java.text.SimpleDateFormat;
import java.util.List;


public class ItemAdapter extends ArrayAdapter {
    private final int resourceId;

    public ItemAdapter(Context context, int textViewResourceId, List<Item> itemList) {
        super(context, textViewResourceId, itemList);
        resourceId = textViewResourceId;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Item item = (Item) getItem(position); // 获取当前项的Fruit实例
        View view = LayoutInflater.from(getContext()).inflate(resourceId, null);//实例化一个对象
        TextView content = (TextView) view.findViewById(R.id.content);//获取该布局内的图片视图
        TextView date = (TextView) view.findViewById(R.id.date);//获取该布局内的图片视图





        content.setText(item.getContent());//为文本视图设置文本内容

        SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd/HH:mm:ss");
        String x = sdf.format(item.getDate());
        date.setText(x);



        return view;
    }
}
